<?php
   include_once($_SERVER['DOCUMENT_ROOT']."/swo.cfg.php");
   require_once("$root_path/cfg/dbLogin.cfg.php");
   //error_reporting(0);
   class DBManager extends DBConfig
   {
     private $mysqli;
	 public $connectionType="Default";
     public function getDBConnection() 
		      {
			     try
				 {
			         $this->mysqli=new mysqli(parent::$server_host,parent::$server_user,
				                        parent::$server_password,parent::$server_db);
				     if (mysqli_connect_errno()) 
                        throw new Exception('Server Database Connection Failed');
					 $this->connectionType="Server";
                  
				 }catch(Exception $e)
				 {
				     //echo 'Caught exception: ',  $e->getMessage(), "\n";
				     try
				      {
				        $this->mysqli=new mysqli(parent::$local_host,parent::$local_user,
				                           parent::$local_password,parent::$local_db);
						if (mysqli_connect_errno()) 
                           throw new Exception('Local Database Connection Failed');
						$this->connectionType="Local";

					  }catch(Exception $e)
					    {
					     //echo 'Caught exception: ',  $e->getMessage(), "\n";
						 header("Location: util/error.php?errCode=100");
					    }
				 }
				 //echo "Connection Created Successfully";
                return $this->mysqli;
			   }
			   
		 function dbClose()
		 {
		    $this->mysqli->close();
			echo "<br />Connection close at dbConnection<br />";
		 }

   }
?>